import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import * as path from 'path';
// 引入Unocss
import Unocss from 'unocss/vite';
import { presetUno, presetAttributify, presetIcons } from 'unocss'
// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  resolve: {
    //设置别名
    alias: {
      '@': path.resolve(__dirname, 'src'),
    },
  }, 
  plugins: [vue(),Unocss( )],
  server: {
    port: 8080,
    cors: true,
    proxy: {
      '/api': {  // 注意这里要加上斜杠
        target: 'http://www.wwlib.cn/index.php',  // 删除末尾的斜杠
        changeOrigin: true,
        rewrite: (path) => {
          console.log(111,path);
          
          return path.replace('', '');
        },
        secure: false
      },
    },
  },
});
